import random
from typing import List, Tuple

import pygame

from src.cfg import NODE_WIDTH, NODE_HEIGHT

class Food:

    def __init__(self, color: Tuple[int]) -> None:
        self.color = color
        self.left = -20
        self.top = -20

    @property
    def position(self) -> Tuple[int]:
        return self.left, self.top

    def set_pos(self, free_pos: List[Tuple[int]]) -> None:
        assert len(free_pos) != 0
        self.left, self.top = random.choice(free_pos)

    def draw(self, sc: pygame.Surface) -> None:
        pygame.draw.rect(
            sc, 
            self.color,
            (self.left, self.top, NODE_WIDTH, NODE_HEIGHT)
        )
